package com.example.controller.admin;

import com.example.base.ResultBaseController;
import com.example.dto.*;
import com.example.entity.Order;
import com.example.service.OrderComplaintService;
import com.example.service.OrderReturnApplyService;
import com.example.service.OrderService;
import com.example.vo.Result;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 朽
 */
@RestController
@Slf4j
@RequestMapping("/admin/order")
public class AdminOrderController extends ResultBaseController<OrderService, Order> {
    @Autowired
    private OrderComplaintService orderComplaintService;

    @Autowired
    private OrderReturnApplyService orderReturnApplyService;

    @GetMapping("/getOrderList")
    @Operation(summary = "获取订单信息")
    public Result<List<AdminOrderDto>> getOrderList(){
        return baseService.getOrderList();
    }

    @PostMapping("/search")
    @Operation(summary = "查询订单信息")
    public Result<List<AdminOrderDto>> searchOrder(@RequestBody SearchOrderDto searchOrderDto){
        return baseService.searchOrderList(searchOrderDto);
    }

    @PostMapping("/getOrderDetail")
    @Operation(summary = "查询指定订单详细信息")
    public Result<AdminOrderDetail> getOrderDetail(@RequestParam("orderSn") String orderSn){
        return baseService.getOrderDetail(orderSn);
    }

    @GetMapping("/getComplaints")
    @Operation(summary = "获取投诉信息")
    public Result<List<ComplaintDto>> getComplaints(){
        return orderComplaintService.getOrderList();
    }

    @PostMapping("/searchComplaint")
    @Operation(summary = "查询投诉信息")
    public Result<List<ComplaintDto>> searchComplaint(@RequestBody OrderSearchDto orderSearchDto){
        return orderComplaintService.searchComplaint(orderSearchDto);
    }

    @PostMapping("/getComplaintDetail")
    @Operation(summary = "查询指定投诉详细信息")
    public Result<ComplaintDetailDto> getComplaintDetail(@RequestParam("id") Long id){
        return orderComplaintService.getComplaintDetail(id);
    }

    @GetMapping("/getReturn")
    @Operation(summary = "获取售后信息")
    public Result<List<ReturnApplyDto>> getReturnList(){
        return orderReturnApplyService.getReturnList();
    }

    @PostMapping("/searchReturn")
    @Operation(summary = "查询售后信息")
    public Result<List<ReturnApplyDto>> searchReturn(@RequestBody OrderSearchDto orderSearchDto){
        return orderReturnApplyService.searchReturn(orderSearchDto);
    }

    @PostMapping("/getReturnDetail")
    @Operation(summary = "查询指定售后详细信息")
    public Result<ReturnApplyDto> getReturnDetail(@RequestParam("id") Long id){
        return orderReturnApplyService.getReturnDetail(id);
    }
}
